<template>
    <view>
        <m-header @reload="" @search="search"></m-header>
        <view v-for="(item, index) in form_data.lists" :key="index">
            <view class="record-cell" v-if="item.name.includes(searchText)">
                <view class="remark">
                    <text style="flex: 0 0 auto; margin-right: 20rpx">学员名称</text>
                    <text>{{ item.name }}</text>
                </view>

                <view class="flex-c-s">
                    <view class="remark2">
                        <text style="flex: 0 0 auto">缘由:</text>
                        <text>{{ item.type == 1 ? '充值' : '打卡扣费' }}</text>
                    </view>
                    <view class="flex-c remark2">
                        <text>次数:</text>
                        <view style="font-weight: 600">
                            <text :style="{ color: item.type == 0 ? '#000' : '#eb4349' }">{{ item.type == 1 ? '+' : '-' }}{{ item.money }}</text>
                        </view>
                    </view>
                    <view class="flex-c remark2">
                        <text>剩余:</text>
                        <text>{{ item.balance }}</text>
                    </view>

                    <view class="remark2" v-if="item.typeText">
                        <text>项目:</text>
                        <text>{{ item.typeText }}</text>
                    </view>
                    <view class="remark2" style="margin: 0">
                        <text>时间:</text>
                        <text>{{ item.ctime }}</text>
                    </view>
                </view>

                <view class="remark" v-if="item.note">
                    <text>备注</text>
                    <text>{{ item.note }}</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script setup>
import { ref, reactive, nextTick } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
const searchText = ref('');
const form_data = reactive({});
onLoad((options) => {
    form_data.id = options.id;
    let store = uni.getStorageSync('BalanceList');
    let findObj = [];
    if (form_data.id) {
        findObj = store.filter((item) => item.id == form_data.id && item.type == options.type);
    } else {
        findObj = store.filter((item) => item.type == options.type);
    }
    form_data.lists = findObj;
});
const search = (e) => {
    console.log(e);
    searchText.value = e;
};
</script>

<style lang="scss" scoped>
.record-cell {
    width: 690rpx;
    border-radius: 16rpx;
    margin: 10rpx auto;
    background: #ffffff;
    padding: 12rpx ;

    .remark {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10rpx;
        text:nth-child(1) {
            text-align: left;
            font-size: 22rpx;
            color: #9e9e9e;
        }

        text:nth-child(2) {
            color: #3d3d3d;
            font-size: 24rpx;
            font-weight: bold;
        }
    }
    .remark2 {
        text:nth-child(1) {
            text-align: left;
            font-size: 22rpx;
            color: #9e9e9e;
        }

        text:nth-child(2) {
            color: #3d3d3d;
            font-size: 24rpx;
            font-weight: bold;
        }
    }
}
</style>
